package com.practice.blog.common.pojo;

import com.practice.blog.common.enums.ResultStatusEnums;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-30
 * Time: 11:52
 */
@Data
public class Result<T> {
    private int code;
    private String errMeg;
    private T data;

    public static <T> Result<T> success(T data) {
        Result result = new Result();
        result.setCode(ResultStatusEnums.SUCCESS.getCode());
        result.setData(data);
        result.setErrMeg("没有错误信息");
        return result;
    }

    public static <T> Result<T> fail(String errMeg) {
        Result result = new Result();
        result.setCode(ResultStatusEnums.FAIL.getCode());
        result.setErrMeg(errMeg);
        return result;
    }


    public static <T> Result<T> fail(String errMeg,T data) {
        Result result = new Result();
        result.setCode(ResultStatusEnums.FAIL.getCode());
        result.setData(data);
        result.setErrMeg(errMeg);
        return result;
    }
}
